package com.lanou.controller;

import com.lanou.bean.BlogBean;
import com.lanou.service.BlogService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@ResponseBody
@Controller
public class JsonController {

    @Resource private BlogService blogService;

    @RequestMapping("/writehome")
    private Integer pageWrite(@RequestParam("username") int username){
        System.out.println(username);
        return username;
    }

    @RequestMapping(value = "/addcontent",method = RequestMethod.GET)
    private List<BlogBean> pageAdd(String title, String des,String content){

        BlogBean blogBean = new BlogBean();
        blogBean.setTitle(title);
        blogBean.setDes(des);
        blogBean.setContent(content);

        blogService.addBlog(blogBean);

        List<BlogBean> list = blogService.selectAll();

        return list;


    }




}
